home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 25 / AACD 25.iso / AACD / Graphics / PerfectPaint / rexx / general / LoadTransferAnim.rx < prev    next >
Encoding:
Text File  |  2001-04-20  |  2.9 KB  |  194 lines

  1. /*     arexx Script 
  2. */
  3.  
  4.     call addlib("rexxmathlib.library", 5, -30, 0)
  5.  
  6.     options results
  7.     parse ARG Port b
  8.     
  9.     ADDRESS value Port
  10.  
  11.     if EXISTS('PerfectPaint:Prefs/Rexx_Prefs/LTransferAnim') THEN DO
  12.         IF OPEN('lfile','PerfectPaint:Prefs/Rexx_Prefs/LTransferAnim', "R") then DO
  13.             file = READLN('lfile')
  14.             CALL CLOSE('lfile')
  15.             file2=""
  16.             do i=1 to LENGTH(file)
  17.                 a=SUBSTR(file,i,1)
  18.                 if a=" " then DO
  19.                     a="*"
  20.                 END
  21.                 file2=file2||a
  22.             END
  23.             file=file2
  24.         END
  25.     END
  26.  
  27.     pp_DialogInit 250 80 "*Load*Transfer*Animation" 2
  28.         pp_String 0 50 12 150 16 "file" 1 100 file
  29.         n=LASTPOS('/',file)
  30.         if n=0 then DO
  31.             n=LASTPOS(':',file)
  32.             file=SUBSTR(file,1,n)
  33.         END
  34.         else DO            
  35.             file=SUBSTR(file,1,n)
  36.         END
  37.         pp_Getfile 1 205 13 0 "Select*Path" 0 file
  38.     pp_Dialog    
  39.  
  40.     rc=result
  41.     if rc=0 then
  42.         do
  43.             pp_PermitRefresh            
  44.             EXIT
  45.         end    
  46.  
  47.     pp_GetDialog 0
  48.     file=result
  49.  
  50.     CALL SavePrefs('LTransferAnim',file)
  51.  
  52.     Width=0
  53.  
  54.     if ~exists(file||'.info') then DO
  55.         pp_Warn "Can't*find*'.info'*file."
  56.         pp_DialogInit 250 80 "*Load*Transfer*Animation" 1
  57.             pp_integer 3 50 12 70 16 "Width*of*one*frame" 1 Width
  58.         pp_Dialog
  59.         rc=result
  60.         if rc=0 then DO
  61.             pp_PermitRefresh            
  62.             EXIT
  63.         end
  64.         pp_GetDialog 0
  65.         Width=result            
  66.     END        
  67.         
  68.     if Width=0 then DO
  69.         pp_FindToolvalue file "WIDTH"
  70.         IF result~="" then DO
  71.             Width=result
  72.         END
  73.         ELSE DO
  74.             pp_FindToolvalue file "SIZE"
  75.             IF result~="" then DO
  76.                 W1=LASTPOS(",",result)
  77.                 Width=SUBSTR(result,1,W1-1)                
  78.             END            
  79.             ELSE DO            
  80.                 pp_FindToolValue file "FRAMEWIDTH"
  81.                 IF result~="" then DO    
  82.                     Width=result
  83.                 END    
  84.             END
  85.         END
  86.     END
  87.  
  88.     pp_GetCurrentBuffer
  89.     CBf=result
  90.     pp_GetCurrentBrush
  91.     B0=result    
  92.  
  93.     pp_Load file
  94.     
  95.     pp_GetDepth
  96.     D=result
  97.     pp_GetWidth
  98.     W=result
  99.     pp_GetHeight
  100.     H=result
  101.  
  102.     if D<24 then DO
  103.         pp_Psave "ram:palette.trash" 0
  104.     END
  105.     
  106.     pp_FindEmptyBrush
  107.     Brush=result
  108.     if Brush=-1 then DO
  109.         pp_Warn "can't*find*empty|Brush."
  110.         EXIT        
  111.     END
  112.     pp_SetBrush Brush
  113.  
  114.     pp_FindEMptyBuffer
  115.     Bf=result
  116.     if Bf=-1 then DO
  117.         pp_Warn "can't*find*empty|Buffer."
  118.         EXIT        
  119.     END
  120.     pp_SetBuffer Bf
  121.  
  122.     pp_New Width H D
  123.     pp_GetWidth
  124.     if result=0 then DO
  125.         pp_Warn "Not*enough*memory."
  126.         EXIT            
  127.     END
  128.  
  129.     pp_AnimGui 1
  130.     IF result<2 then DO
  131.         EXIT
  132.     END
  133.     count=trunc(W/Width)
  134.     pp_MakeAnim count
  135.     pp_CountFrames
  136.     IF result<2 then DO
  137.         pp_Warn "Can't*create*animation."
  138.         EXIT
  139.     END
  140.  
  141.     if D<24 then DO
  142.         pp_Pload "ram:palette.trash"
  143.         ADDRESS COMMAND
  144.         'delete >nil: ram:palette.trash'
  145.         ADDRESS value Port
  146.     END
  147.  
  148.     X2=Width/2
  149.     Y2=H/2
  150.  
  151.     PB=0
  152.  
  153.     DO i=1 to count
  154.         pp_SetBuffer CBf
  155.         pp_PickBrush PB 0 Width H
  156.         pp_SetBuffer Bf
  157.         pp_Plot X2 Y2
  158.         pp_NextFrame
  159.         PB=PB+Width
  160.     END
  161.  
  162.     pp_SetBuffer CBf
  163.     pp_ClearCurrentBuffer
  164.     pp_SetBuffer Bf    
  165.  
  166.     pp_FreeBrush
  167.     pp_SetBrush B0
  168.  
  169.  
  170.     EXIT
  171.  
  172. SavePrefs: PROCEDURE
  173.     
  174.     Prefname='PerfectPaint:Prefs/Rexx_Prefs/'||ARG(1)
  175.  
  176.     if EXISTS(Prefname) THEN DO
  177.         ADDRESS COMMAND
  178.         'delete >nil: '||Prefname
  179.     END
  180.  
  181.     IF OPEN('pfile',PrefName,'W') THEN DO
  182.  
  183.     do i=2 to ARG()
  184.         CALL WRITELN('pfile',ARG(i))
  185.     end
  186.  
  187.     CALL CLOSE('pfile')
  188.  
  189. RETURN    
  190.  
  191.  
  192.     
  193.  
  194.